<%@page contentType="text/html"  import="java.util.Collection, Bean.*"%>
<%@page pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/taglib139.tld" prefix="pg" %>
<%--
The taglib directive below imports the JSTL library. If you uncomment it,
you must also add the JSTL library to the project. The Add Library... action
on Libraries node in Projects view can be used to add the JSTL 1.1 library.
--%>

<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 

<%
if(session.getAttribute("un")==null){
    response.sendRedirect("indexAdmin.jsp?page=Admin&url=Login");
    out.println("You must be login..!");
}else{%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        
        <form action="Serachuser" name="formSuser" id="formSuser" method="get" >
            <h3 align="center">Search Users</h3>
            <table>
                <tr>
                    <td>UserName: </td>
                    <td><input type="text" name="txtsearch" value="" /></td>
                    <td><input type="submit" name="bt" value="Search"  /> <a href="indexAdmin.jsp?page=Admin&url=user">Back..!</a></td>
                </tr>
            </table>
            <br>
            
            <c:if test="${not empty sear}">
                <table border="1">
                    <tr>
                        <th>No.</th>
                        <th>User Name</th>
                        <th>Full Name</th>
                        <th>Address</th>
                        <th>Phone</th>
                        <th>Email</th>
                        <th>Gender</th>
                        <th>Question</th>
                        <th>Status</th>
                       <th colspan="2">Action</th>
                    </tr>
                    <c:set var="count" value="0"/>
                        <c:forEach items="${sear}" var="rows">
                                <c:set var="count" value="${count+1}" />
                                <tr>
                                    <td>${count}</td>
                                    <td><c:out value="${rows.username}" /></td>
                                    <td><c:out value="${rows.fullname}" /></td>
                                    <td><c:out value="${rows.address}" /></td>
                                    <td><c:out value="${rows.phone}" /></td>
                                    <td><c:out value="${rows.email}" /></td>
                                    <td><c:out value="${rows.gender}" /></td>
                                    <td><c:out value="${rows.question}" /></td>
                                    <td><c:out value="${rows.status}" /></td>
                                    <c:url var="edit" value="Serachuser">
                                        <c:param name="bt" value="Edit" />
                                        <c:param name="username" value="${rows.username}" />
                                        <c:param name="fullname" value="${rows.fullname}" />
                                        <c:param name="address" value="${rows.address}" />
                                        <c:param name="phone" value="${rows.phone}" />
                                        <c:param name="email" value="${rows.email}" />
                                        <c:param name="gender" value="${rows.gender}" />
                                        <c:param name="question" value="${rows.question}" />
                                        <c:param name="status" value="${rows.status}" />
                                        <c:param name="p" value="${param.pageNum}"/> 
                                    </c:url> 
                                    <c:url var="delete" value="Serachuser">
                                        <c:param name="bt" value="Delete" />
                                        <c:param name="username" value="${rows.username}" />
                                        <c:param name="txtsearch" value="${param.txtsearch}" />
                                    </c:url>
                                    <td><a href="${edit}">Edit</a></td>
                                    <td><a href="${delete}" onclick="return confirm('Do you really want to delete these records ?')">Delete</a></td>
                                </tr>
                        </c:forEach>
                </table>
            </c:if>
        </form>
        
    </body>
</html>
<%}%>
